  const sendCmd = (id,API_KEY, data)=>{
    var deviceConnected;
    //查看设备连接状态，并刷新按钮状态
    wx.request({
      url: ("https://api.heclouds.com/cmds?device_id="+id),
      header: {
        'content-type': 'application/json',
        "api-key": API_KEY
      },
      data: data,
      method: 'POST',
      success(res) {
        console.log(res)
      },
      fail(res) {
        console.log("请求失败")
        deviceConnected = false
      },
      complete() {
        if (deviceConnected) {
          console.log("complete ok")
          return true
        } else {
          console.log("complete error")
          return false
        }
      }
    })
  };

  module.exports={
    sendCmd
  }